package com.gitee.absolute_spirit.hiot_android.data.source.network

import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class DeviceNetworkDao @Inject constructor(
    private val deviceNetworkService: DeviceNetworkService
) {
    suspend fun getAll() = deviceNetworkService.getAll()

    val devices: Flow<List<NetworkDevice>> = flow {
        while (true) {
            val devices = deviceNetworkService.getAll()
            emit(devices)
            delay(60*1000)
        }
    }
}